#!/bin/bash

echo "=== 完成 wxWidgets 库引用修复 ==="

# 备份
cp cbp2make_aicoder_wx32_64.cbp cbp2make_aicoder_wx32_64.cbp.backup_final

# 1. 移除所有旧的 wxWidgets 库引用
echo "移除旧的库引用..."
sed -i '/wx_mswu_adv_3.2/d' cbp2make_aicoder_wx32_64.cbp
sed -i '/wx_scintilla_3.2/d' cbp2make_aicoder_wx32_64.cbp
sed -i '/wx_advu/d' cbp2make_aicoder_wx32_64.cbp
sed -i '/wx_scintilla/d' cbp2make_aicoder_wx32_64.cbp

# 2. 添加正确的库引用（去掉 lib 前缀和 .dll.a/.a 后缀）
echo "添加正确的库引用..."
sed -i '/<Linker>/a\        <Add library="wx_mswu_adv-3.2"/>' cbp2make_aicoder_wx32_64.cbp
sed -i '/<Linker>/a\        <Add library="wxscintilla-3.2"/>' cbp2make_aicoder_wx32_64.cbp

# 3. 确保库搜索路径正确
echo "确保库搜索路径..."
if ! grep -q "D:/vc/wxWidgets-3.2.7/lib" cbp2make_aicoder_wx32_64.cbp; then
    sed -i '/<Linker>/a\        <Add directory="D:/vc/wxWidgets-3.2.7/lib"/>' cbp2make_aicoder_wx32_64.cbp
fi

echo "✅ 修复完成！"
